package cn.exrick.xboot.modules.backlogOrFullList.sqlprovider;

import cn.exrick.xboot.modules.base.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: njp
 * @Date: 2020/07/06/11:11
 * @Description:
 */
@Slf4j
public class BackLogSqlProvider {
        public String batchDelete(@Param("userlist") List<User> userlist) {

            StringBuffer sql=new StringBuffer();
            sql.append("delete from  t_backlog_or_full_list where user_code in (");
            int size = userlist.size();
            for (int i=0;i<userlist.size();i++){
                sql.append("'");
                sql.append(userlist.get(i).getIdcard());
                sql.append("'");
                StringBuffer stringBuffer = size > 1 && i + 1 != size ? sql.append(",") : null;
            }
            sql.append(") and t_backlog_or_full_list.code='todo'");
            log.info("BackLogSqlProvider:batchDelete:"+sql.toString());
            return sql.toString();
        }
}
